package com.atguigu.domain.strategy.respository;

import com.atguigu.domain.strategy.model.entity.StrategyAwardEntity;
import com.atguigu.domain.strategy.model.entity.StrategyEntity;
import com.atguigu.domain.strategy.model.entity.StrategyRuleEntity;
import com.atguigu.domain.strategy.model.vo.RuleTreeVO;
import com.atguigu.domain.strategy.model.vo.RuleWeightVO;
import com.atguigu.domain.strategy.model.vo.StrategyAwardRUleModelVO;
import com.atguigu.domain.strategy.model.vo.StrategyAwardStockKeyVO;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface IStrategyRepository {
    List<StrategyAwardEntity> queryStrategyAwardList(long strategyId);

    void storeStrategyAwardSearchRateTable(String strategyId, int size, Map<Integer, Integer> shuffleStrategyAwardSearchRateTable);

    Integer getRateRange(long strategyId);

    Integer getRateRange(String strategyId);

    Integer getStrategyAwardAssemble(String key, int rateKey);

    StrategyEntity queryStrategyEntityById(long strategyId);

    StrategyRuleEntity queryStrategyRule(long strategyId, String ruleModel);

    String queryStrategyRuleValue(Long strategyId, Integer awardId, String ruleModel);

    String queryStrategyRuleValue(Long strategyId, String ruleModel);

    StrategyAwardRUleModelVO queryStrategyAwardRUleModel(Long strategyId, Integer awardId);

    RuleTreeVO queryRuleTreeVOBYTreeId(String treeId);

    void storeStrategyAwardCount(String cacheKey, Integer awardCount);

    Boolean subtractionAwardStock(String cacheKey, Date endDateTime);

    void awardStockConsumeSendQueue(StrategyAwardStockKeyVO strategyAwardStockKeyVO);

    StrategyAwardStockKeyVO takeQueueValue() throws InterruptedException;

    void updateStrategyAwardStock(Long strategyId, Integer awardId);

    StrategyAwardEntity queryStrategyAwardEntity(Long strategyId, Integer awardId);

    Long queryStrategyIdByActivityId(Long activityId);

    Integer queryTodayUserRaffleCount(String userId, Long strategyId);

    Map<String, Integer> queryAwardRuleCount(String[] treeIds);

    /**
     * 根据用户ID、策略ID，查询用户活动账户总使用量
     *
     * @param userId     用户ID
     * @param strategyId 策略ID
     * @return 使用总量
     */
    Integer queryActivityAccountTotalUseCount(String userId, Long strategyId);

    /**
     * 查询奖品权重配置
     *
     * @param strategyId 策略ID
     * @return 权重规则
     */
    List<RuleWeightVO> queryAwardRuleWeight(Long strategyId);

}
